<?php
/**
 * Created by PhpStorm.
 * User: Celebration-Grey
 * Date: 2017/4/18
 * Time: 21:00
 */

namespace App\Http\Classes;
use Illuminate\Support\Facades\DB;


class Author
{
    public $user_id = null;
    private $db;
    public function __construct($user_id)
    {
        $this->user_id = $user_id;
        $this -> connection();
    }

    private function connection(){
        $this->db = DB::table('weibo_users')->where('user_id', '=', $this->user_id);
    }

    public function bowenAuthor(){
        $result = $this->db->select(
            'user_id',
            'user_nickname',
            'user_level',
            'user_head_img'
        )->get();
        if($result){
            return $result[0];
        }
        else{
            return null;
        }
    }

    public function commentAuthor(){
        $result = $this->db->select(
            'user_id',
            'user_nickname',
            'user_level',
            'user_head_img'
        )->get();
        if($result){
            return $result[0];
        }
        else{
            return null;
        }
    }

    public function replyAuthor(){
        $result = $this->db->select(
            'user_id',
            'user_nickname',
            'user_level'
        )->get();
        if($result){
            return $result[0];
        }
        else{
            return null;
        }
    }

    public function infoAuthor(){
        $result = $this->db->select(
            'user_id',
            'user_nickname',
            'user_level',
            'user_head_img',
            'user_card_img',
            'user_bowen_count',
            'user_following_count',
            'user_followed_count',
            'user_info',
            'user_sex',
            'user_school',
            'user_work',
            'user_city',
            'user_province'
        )->get();
        if($result){
            return $result[0];
        }
        else{
            return null;
        }
    }
}